package com.ht.controller;

import com.ht.pojo.UserRecord;
import com.ht.service.EmpService;
import com.ht.vo.PageResult;
import com.ht.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author d
 * @version 1.0
 * @description: TODO
 * @date 2021/7/17 14:15
 */
@RestController
@CrossOrigin
@RequestMapping("/emp")
public class UserController {

    @Autowired
    private EmpService empService;

    @GetMapping("/list")
    public SysResult getUserList(PageResult pageResult) {

        pageResult = empService.getUserList(pageResult);
        return SysResult.success(pageResult);
    }

    @PutMapping("/status/{id}/{status}")
    public SysResult updateStatus(UserRecord user_record) {
        empService.updateStatus(user_record);
        return SysResult.success();
    }

    @PostMapping("/addUser")
    public SysResult saveAddUser(@RequestBody UserRecord user_record) {
        empService.saveaddUser(user_record);
        return SysResult.success();
    }

    @GetMapping("id")
    public SysResult selectUser(@PathVariable Integer id){
        UserRecord user_record = empService.selectUser(id);
        return SysResult.success(user_record);
    }

    @PutMapping("updateUser")
    public SysResult updateUser(@RequestBody UserRecord user_record){
        empService.updateUser(user_record);
        return SysResult.success();
    }
}
